Skip to content

⚡ Bolt: optimize line start lookups in indent and goto-line - #1038

Merged
dezren39 merged 3 commits into
mainfrom
bolt-optimize-indent-goto-line-3005372216330354434
Oct 30, 2026
Merged

dezren39 merged 3 commits into
mainfrom
bolt-optimize-indent-goto-line-3005372216330354434

Conversation

@dezren39

@dezren39 dezren39 commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

💡 What:
Optimized selectedLineStarts and dedentCommand in pkgs/id/web/src/indent.ts, and avoided duplicate document AST traversals in pkgs/id/web/src/goto-line.ts.

🎯 Why:

  1. In indent.ts, selectedLineStarts previously performed linear O(N) scans (lineStarts.includes(to)) and O(N) array filtering across all lines in the document. For single-cursor dedentCommand, lineStarts.filter contained a nested lineStarts.indexOf(ls), creating an O(N²) bottleneck for long files.
  2. In goto-line.ts, submitting a target line number computed getLineStarts(activeView) twice sequentially (getLineCount and getLineStartPos), traversing the ProseMirror document AST twice.

📊 Impact:

  • indent.ts: Reduces line position lookups from O(N²) / O(N) to O(log N) binary search and O(M) range slicing, eliminating quadratic degradation during indent/dedent operations in large code blocks.
  • goto-line.ts: Cuts document AST traversal in half during jump operations.

🔬 Measurement:

  • Run Vitest tests (cd pkgs/id/web && ./node_modules/.bin/vitest run) - all 401 unit tests pass.
  • Run typecheck (cd pkgs/id/web && ./node_modules/.bin/tsc --noEmit).

PR created automatically by Jules for task 3005372216330354434 started by @dezren39


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

- Replace O(N) includes() and O(N) filter() in indent.ts with O(log N) binary search and O(M) range slicing.
- Eliminate O(N^2) filter + indexOf loop in dedentCommand for single-cursor selections.
- Avoid duplicate document AST traversal in goto-line dialog on submission.

Co-authored-by: dezren39 <11225574+dezren39@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4ce0c740-28d1-41a8-8654-1ebbcdab24f8
Commits

Reviewing files that changed from the base of the PR and between 70efcd4 and a1cb58c.

Files selected for processing: 3
  • .jules/bolt.md
  • pkgs/id/web/src/goto-line.ts
  • pkgs/id/web/src/indent.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

google-labs-jules Bot and others added 2 commits October 27, 2026 01:36
- Replace O(N) includes() and O(N) filter() in indent.ts with O(log N) binary search and O(M) range slicing.
- Eliminate O(N^2) filter + indexOf loop in dedentCommand for single-cursor selections.
- Avoid duplicate document AST traversal in goto-line dialog on submission.
- Format modified files with Biome formatter.

Co-authored-by: dezren39 <11225574+dezren39@users.noreply.github.com>
- Replace O(N) includes() and O(N) filter() in indent.ts with O(log N) binary search and O(M) range slicing.
- Eliminate O(N^2) filter + indexOf loop in dedentCommand for single-cursor selections.
- Avoid duplicate document AST traversal in goto-line dialog on submission.
- Format modified files with Biome formatter.

Co-authored-by: dezren39 <11225574+dezren39@users.noreply.github.com>
@dezren39
dezren39 marked this pull request as ready for review October 30, 2026 04:42
@dezren39
dezren39 requested a review from a team as a code owner October 30, 2026 04:42
@dezren39
dezren39 merged commit 4675ddc into main Oct 30, 2026
28 checks passed
@dezren39
dezren39 deleted the bolt-optimize-indent-goto-line-3005372216330354434 branch October 30, 2026 04:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T04:43:46.517149Z a1cb58c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant